package com.pet.shop.service.pet;

import com.github.pagehelper.Page;
import com.pet.shop.dto.PageDto;
import com.pet.shop.entity.shop.PetDisinsection;
import com.pet.shop.mappers.shop.PetDisinsectionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PetDisinsectionServiceImpl implements IPetDisinsectionService {

    @Autowired
    private PetDisinsectionMapper petDisinsectionMapper;

    @Override
    public int deleteEntity(Long id) {
        return petDisinsectionMapper.delete(id);
    }

    @Override
    public int deleteEntityList(List<Long> idList) {
        if(idList == null || idList.isEmpty()) return 0;
        int i = 0;
        for (Long id : idList) {
            i += petDisinsectionMapper.delete(id);
        }
        return i;
    }

    @Override
    public PetDisinsection insertEntity(PetDisinsection record) {
        petDisinsectionMapper.insert(record);
        return record;
    }

    @Override
    public PetDisinsection getEntity(Long id) {
        return petDisinsectionMapper.get(id);
    }

    @Override
    public int updateEntity(PetDisinsection record) {
        return petDisinsectionMapper.update(record);
    }

    @Override
    public PageDto<PetDisinsection> queryPage(PageDto<PetDisinsection> pageDto) {
        Page<PetDisinsection> page = petDisinsectionMapper.queryPage(pageDto);
        pageDto.setPageResult(page);
        return pageDto;
    }
}
